package com.lvhx.springboot.springbatch.readfile;

import com.lvhx.springboot.entity.User;
import com.lvhx.springboot.mapper.UserMapper;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;
import java.util.List;

/**
 * @auther 吕宏旭
 * @date 2019/9/4 14:48
 */
public class FileWriter implements ItemWriter<User> {
    @Autowired
    private UserMapper userMapper;
    @Override
    public void write(List<? extends User> list) throws Exception {
        for (User user : list){
            System.out.println(user.getName());
            userMapper.insert(user);
        }
    }
}
